<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%> 
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%  
    String path = request.getContextPath();  
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户管理</title>
<link rel="stylesheet" href="css/bootstrap.css" />
<link rel="stylesheet" href="css/css.css" />
<script type="text/javascript" src="js/jquery1.9.0.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/sdmenu.js"></script>
<script type="text/javascript" src="js/laydate/laydate.js"></script>
<script type="text/javascript" src="widget/jqGrid/jquery.jqGrid.src.js"></script>
<script type="text/javascript" src="widget/jqGrid/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="widget/jqGrid/jquery.jqGrid.min.js"></script>
<link href="../style/authority/basic_layout.css" rel="stylesheet" type="text/css">
<link href="../style/authority/common_style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="../style/authority/jquery.fancybox-1.3.4.css" media="screen"></link>
<link type="text/css" rel="stylesheet" href="widget/jqGrid/redmond/jquery-ui-1.8.2.custom.css"/>
<link type="text/css" rel="stylesheet" href="widget/jqGrid/ui.jqgrid.css"/> 
<title>项目信息</title>
</head>

<body> 
<script type="text/javascript">
var myMenu;
window.onload = function() {
	myMenu = new SDMenu("my_menu");
	myMenu.init();
};
</script>

     <div class="Switch"></div>
     <script type="text/javascript">
	$(document).ready(function(e) {
    $(".Switch").click(function(){
	$(".left").toggle();
	 
		});
});
</script>
 <script>
!function(){
laydate.skin('molv');
laydate({elem: '#Calendar'});
laydate.skin('molv');
laydate({elem: '#Calendar2'});
}();
</script>
<script type="text/javascript">
$(document).ready(function(){
    $("#projectTable").jqGrid({
    	url:"http://localhost:8080/wanda/sale/List.action",
        datatype:"json", 
        mtype:"POST",
        height:400,
        //postData:"{pageSize:10,pageIndex:1,SearchSql:''}",
        width:1025, 
        colNames:['id','客户姓名','性别','身份证','电话','通讯地址','接待员','户型','来访类型','客户类型','楼栋','单元','房间号',],
        colModel:[ 
{name:'id',index:'id', width:'40%',align:'center',hidden:true},                  
{name:'cname',index:'cname', width:'40%',align:'center'},
{name:'sex',index:'sex', width:'40%', align:'center'},
{name:'idcard',index:'idcard', width:'40%', align:'center'},
{name:'phonenum',index:'phonenum', width:'40%', align:'center'},
{name:'address',index:'address', width:'40%', align:'center'},
{name:'rpeople',index:'rpeople', width:'40%', align:'center'},
{name:'doormodel',index:'doormodel', width:'40%', align:'center'},
{name:'visittype',index:'visittype', width:'40%', align:'center'},
{name:'customertype',index:'customertype', width:'40%', align:'center'},
{name:'floor',index:'floor', width:'40%', align:'center'},
{name:'unit',index:'unit', width:'40%', align:'center'},
{name:'roomnum',index:'roomnum', width:'40%', align:'center'},
        ],
        rownumbers:true,
        shrinkToFit:true,
       // caption:"学生表",
        //altRows:true,
        //sortname:'createDate',
        //sortorder:'asc',
        viewrecords: true,
        rowNum:10,
        rowList:[10,20,30],
        jsonReader:{
            id: "blackId",
            repeatitems : false
        },
        pager:$('#gridPager')
    });
});
	/** 新增   **/
	function add(){
        	 $.ajax({
            	 type: "POST",
             	 url: "sale/query.action",
             	 data: {
             		cname:$("#cname").val(),
             		sex:$("#sex").val(),
             		visittype:$("#visittype").val(),
             		customertype:$("#customertype").val(),
             		idcard:$("#idcard").val(),             		
             		phonenum:$("#phonenum").val(),
             		address:$("#address").val(),
             		rpeople:$("#rpeople").val(),
             		doormodel:$("#doormodel").val(),
             		floor:$("#floor").val(),
             		unit:$("#unit").val(),
             		roomnum:$("#roomnum").val()},           		
              	 dataType: "json",
              	success:function(data){ 
              		alert("添加成功。");
                	window.location.href= "SaleChanceList.jsp";
             	 }, 
            	error: function(data){
            		alert("请认真核对信息！"); 
            	}
        	 });
	}
	
/** 删除   **/
	function ajaxDelete(){  
    var id=$('#projectTable').jqGrid('getGridParam','selrow');
    if(id==null)
    	{
    	alert("请选择要删除的行");
    	return;
    	}
    var rowData = $('#projectTable').jqGrid('getRowData',id);
    delid=rowData.id;
      //alert(delid);

    $.ajax({  
    data: {id:id},  
    type:"Post",  
    dataType: 'json',  
    url:"http://localhost:8080/wanda/sale/delete.action", 
     error:function(data){ 
    	 alert("出错了！！"); 
     },  
    success:function(data){  
    	 
    	  $("#projectTable").jqGrid('setGridParam',{ 
              datatype:'json', 
              postData:{'SearchSql':""}, // 发送数据   
              page:1 
          }).trigger("reloadGrid"); 
      	alert("删除成功");
     }  
     });  
 } 
 		/* 修改 */
	function ajaxUpdate(){  
		
		var id=$('#projectTable').jqGrid('getGridParam','selrow');
		if(id==null)
		{
		alert("请选择要修改的行");
		return;
		}
	   var rowData = $('#projectTable').jqGrid('getRowData',id);
	   id=rowData.id;
	   //alert("rid:"+rid);
	   window.location.href="UpdateSaleChance.jsp?id="+id;
	   
	 }  
	function checkMessage(){
		var cname = $("#cname").val();
		var age = $("#age").val();
		var sex = $("#sex").val();
		var idcard = $("#idcard").val();
		var phonenum = $("#phonenum").val();
		var address = $("#address").val();
		  if(cname==""){
			 alert("姓名不能为空！");
			 $("#cname").focus();
			 return false;
		  }
		  if(age==""){
				 alert("年龄不能为空！"); 
				 $("#age").focus();
				 return false;
			  }
		  if(sex==""){
				 alert("请选择性别！"); 
				 $("#sex").focus();
				 return false;
			  }
		  if(idcard==""){
				 alert("身份证号码不能为空！"); 
				 $("#idcard").focus();
				 return false;
			  }
		  if(phonenum==""){
				 alert("联系方式不能为空！"); 
				 $("#phonenum").focus();
				 return false;
			  }
		  if(address==""){
				 alert("通讯地址不能为空！"); 
				 $("#address").focus();
				 return false;
			  }
		  return true;
	   }
</script>
<div class="right"  id="mainFrame">
     <div class="right_cont">
 		<ul class="breadcrumb">
 			当前位置：<a href="#">首页</a> <span class="divider">/</span>
  			<a>用户管理</a> <span class="divider">/</span>销售机会列表
		</ul>
      	<div class="title_right"><span class="pull-right margin-bottom-5">
      	<a  class="btn btn-info btn-small"  id="modal-9735581" href="#modal-container-9735581" role="button" data-toggle="modal">
      	<i class="icon-plus icon-white"></i> 添加销售机会</a></span>
      	<strong>销售机会列表</strong>
      	<span class="pull-right margin-bottom-5">
      	<a  class="btn btn-info btn-small"  id="modal-9735581" href="javascript:void(0);" onclick="ajaxDelete()" role="button" data-toggle="modal">
      	<i class="icon-plus icon-white"></i> 删除机会</a>
      	</span>
      	<span class="pull-right margin-bottom-5">
      	<a  class="btn btn-info btn-small"  id="modal-9735581" href="javascript:void(0);" onclick="ajaxUpdate()" role="button" data-toggle="modal">
      	<i class="icon-plus icon-white"></i> 修改机会</a>
      	</span>
      	</div>
    	<div id="modal-container-9735581" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:600px; margin-left:-300px; top:20%">
				<div class="modal-header">
					 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<h3 id="myModalLabel">添加销售机会</h3>
		</div>
<!-- 弹出层部分 -->
<form name="f1" method="post">
<div class="modal-body">
<table class="table table-bordered">
<tbody>
 	<tr>
 	<input type="hidden" name="id"/>
      <td align="right">客户姓名:</td>
      <td align="left">
      <input type="text" name="cname" id="cname"  class="span1-1" /></td>
      <td align="right">性别</td>
      <td align="left"><input name="sex" id = "sex" type="radio" class="span1-1" value="男"/>男
      <input name="sex" id = "sex" type="radio" class="span1-1" value="女"/>女</td>
    </tr>
    
    <tr>
      <td align="right">身份证号:</td>
      <td align="left" colspan="3"><input type="text" name="idcard" id="idcard"  class="span1-1" /></td>
      <td align="right">联系方式:</td>
      <td align="left"><input type="text" name="phonenum" id="phonenum"  class="span1-1" /></td>
    </tr>
    <tr>
      <td align="right">接待员:</td>
      <td align="left"><input type="text" name="rpeople" id="rpeople"  class="span1-1" /></td>
      <td align="right">来访类型:</td>
      <td align="left"><select name="visittype" id="visittype" class=" span1-1">
            <option>电话</option>
            <option>网络</option>
          </select>  </td>
    </tr>
    <tr>
    <td align="right">客户类型:</td>
      <td align="left"><select name="customertype" id="customertype" class=" span1-1">
            <option>个人</option>
            <option>公司</option>
          </select>
      </td>
       <td align="right">通讯地址:</td>
      <td align="left"><input type="text" name="address" id="address" class="span1-1"  />
      </td>
    
    </tr>
  </tbody>
</table>
</div>	
<div class="modal-footer">
	
	<input type="button" value="添加" id = "addBtn" onclick="return checkMessage()&&add()"/>
    <input type="reset" value="取消" />
</div>
</div>
</form>
   <table name="projectTable" id="projectTable" class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
						
					</table>
					<div id="gridPager"></div>
				</div>
   <!-- 
   <table  class="margin-bottom-20 table  no-border" >
      <tr>
     	<td class="text-center"><input type="button" value="导出" class="btn btn-info" style="width:80px;" /></td>
      </tr> 
   </table>
   -->
</div>
</div>     
</body>
</html>

